Skip to content

fix(web): third dogfood pass on sign-out note, invite undo, payment edit rule - #43

Merged
musa-kal merged 9 commits into
mainfrom
fix/dogfood-3
Nov 16, 2026
Merged

musa-kal merged 9 commits into
mainfrom
fix/dogfood-3

Conversation

@musa-kal

Copy link
Copy Markdown
Member

Intent

Fixes from the third dogfood check:

  1. After Sign out everywhere, a device found by the 30 s check lands on sign in with the note saying why (the note is set as soon as the check finds the session missing, before sign-out; the sign-in page also picks up a note that arrives after it opened).
  2. Revoking an invite leaves an inline "Invite revoked. That link is closed." row with Undo in the sheet, reachable by keyboard, one tap; the toast shows only after the sheet closes.
  3. The viewer's own row on the expense page uses second-person verbs ("You owe", "You get back") in all five languages.
  4. The blocked-person note on the expense form reads well for one or several names.
  5. While a payment is held after a lost reply, the settle screen's debt line shows the amount owed when it was sent.
  6. One rule (mayEditPayment) decides the Edit button and the /payments/:id/edit route; anyone it refuses is sent back to the payment page.
    No server changes. Must keep: i18n for every string, no dashes.

What Changed

  • Session end and invites: confirmSession now leaves the "session ended" note before it signs out, both when the session is missing and when the account is gone. A new onSessionEnded listener lets an already open sign-in page show a note that arrives late. When you revoke an invite, the sheet shows an inline "Invite revoked" row with an Undo button for 8 seconds. It is a real button, so it works from the keyboard. If a revoke is still undoable when the sheet closes, or its reply comes back after the panel is gone, the Undo moves to a toast.
  • Payments: a new mayEditPayment rule in settle/payment-rules.ts controls three places: the Edit button on the payment page, the Edit item in the expenses-list payment menu (now hidden for archived groups), and the /payments/:id/edit route. The route now sends refused viewers back to the payment page with replace. While a payment is held after a lost reply, the settle form's debt line keeps the amount that was owed when it was sent.
  • Copy (en, de, es, fr, pt): new expenses.detail.you.* strings give the viewer's own row on the expense page second-person verbs ("owe", "get back"). The "you blocked" note on the expense form is reworded so it reads correctly with one name or several. Unit tests (including a new edit-payment.test.tsx), the account and invite e2e specs, and docs/development.md and docs/testing.md are updated to match.

Risk Assessment

✅ Low: Client-only UI and copy changes with no server changes; the fix-round code (one Undo note per revoked invite, inSheet toasts, a late-reply toast, mayEditPayment in the expenses-list menu with archived gating) traces correctly through concrete sequences and matches the intent and the recorded user decisions.

Testing

  • ⏭️ Test - skipped

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed (3) ✅
  • ⚠️ apps/web/src/features/settle/settlement-actions.tsx:53 - Intent item 6 says one rule (mayEditPayment) decides the Edit button and the edit route. A second Edit entry point still uses its own copy of the rule: the payment menu in the group's expenses list (SettlementActions, rendered from expenses-tab.tsx:373 with no archived check). Its check is can(viewerRole, 'settlement.edit', { isParty }) plus its own blocked-side check, and it never looks at archived_at. Concrete path: in an archived group, a party opens the payment's menu in the expenses tab and taps Edit. That navigates to /payments/:id/edit, and EditPayment now gets mayEditPayment(...) === false (archived) and replaces the URL with the payment page. The user taps Edit and lands back on the payment page with no form and no explanation. Before this change the form at least opened. Fix: decide this Edit link with mayEditPayment, passing archived from the group (expenses-tab already computes it at line 130), and drop the parallel can(...) check. Delete in the same menu also shows in archived groups (pre-existing; the server refuses with group_archived), so it may be worth gating on archived in the same edit.
  • ℹ️ apps/web/src/lib/auth.ts:216 - Simplification: sessionIsGone accepts error.code === 'session_ended', and the use-session-check test covers it. confirmSession only calls supabase.auth.getUser(), which talks to Supabase Auth (GoTrue). session_ended is this app's own Postgres error code and is never a GoTrue /user response, so this branch cannot be reached from confirmSession. auth-js also already maps session_not_found to AuthSessionMissingError. No intent requirement needs the extra code. The narrower form is AuthSessionMissingError || session_not_found || user_not_found. Remove the session_ended match and its test case unless a caller really passes database errors here.

🔧 Fix applied.
2 issues (1 warning, 1 info) still open:

  • ⚠️ apps/web/src/features/invites/invite-sheet.tsx:227 - A revoke whose reply arrives after the panel has unmounted leaves no Undo anywhere. The revoke mutation's onSuccess now only calls setUndoable. TanStack runs useMutation callbacks even after unmount, so this is a no-op once the panel is gone. The unmount cleanup (line 188) has already run with undoable null, so no toast shows either. Sequence: in the invite sheet, tap Revoke, then close the sheet (Escape or the close button) before the server answers. The link is revoked and there is no inline note and no toast. Before this change, onSuccess raised the toast unconditionally. Fix: keep a mounted ref, and in onSuccess raise the same toast directly (Undo calling restoreRef/restoreInvite) when the panel is no longer mounted. Otherwise setUndoable as now.
  • ℹ️ apps/web/src/features/invites/invite-sheet.tsx:188 - The 'toast when the panel unmounts' rule also applies where InvitePanel is not in a sheet: members-page.tsx:471 renders it inline while the viewer is alone in the group. The undoable state never clears on its own. Sequence: on the members page, revoke a link (the inline note with Undo shows). Some minutes later, navigate to another screen, or have someone join so alone turns false and the panel unmounts. A toast 'Invite revoked. That link is closed.' with Undo then appears on an unrelated screen, long after the action. Intent item 2 only asks for the toast after the sheet closes. Decide whether the inline host should skip the unmount toast, for example a prop on InvitePanel that only InviteSheet sets, or clearing undoable after a timeout.

🔧 Fix applied.
4 issues (1 warning, 3 infos) still open:

  • ⚠️ apps/web/src/features/invites/invite-sheet.tsx:227 - A revoke whose reply arrives after the panel has unmounted leaves no Undo anywhere. The revoke mutation's onSuccess now only calls setUndoable. TanStack runs useMutation callbacks even after unmount, so this is a no-op once the panel is gone. The unmount cleanup (line 188) has already run with undoable null, so no toast shows either. Sequence: in the invite sheet, tap Revoke, then close the sheet (Escape or the close button) before the server answers. The link is revoked and there is no inline note and no toast. Before this change, onSuccess raised the toast unconditionally. Fix: keep a mounted ref, and in onSuccess raise the same toast directly (Undo calling restoreRef/restoreInvite) when the panel is no longer mounted. Otherwise setUndoable as now.
  • ℹ️ apps/web/src/features/invites/invite-sheet.tsx:188 - The 'toast when the panel unmounts' rule also applies where InvitePanel is not in a sheet: members-page.tsx:471 renders it inline while the viewer is alone in the group. The undoable state never clears on its own. Sequence: on the members page, revoke a link (the inline note with Undo shows). Some minutes later, navigate to another screen, or have someone join so alone turns false and the panel unmounts. A toast 'Invite revoked. That link is closed.' with Undo then appears on an unrelated screen, long after the action. Intent item 2 only asks for the toast after the sheet closes. Decide whether the inline host should skip the unmount toast, for example a prop on InvitePanel that only InviteSheet sets, or clearing undoable after a timeout.
  • ℹ️ apps/web/src/features/invites/invite-sheet.tsx:275 - The note's Undo only takes focus when the note mounts. RevokedNote focuses its button in a mount-only effect (line ~402), and its element is not keyed by the revoked invite. When a second link in the same slot is revoked while the note is still up, the same instance stays mounted, so focus is not moved. Sequence: in the sheet, a keyboard user revokes the latest link A (focus lands on Undo), tabs to the new latest link B, and presses Revoke within 8 s. B's row and its focused Revoke button go away, the note now refers to B, and Radix's FocusScope sends focus to the sheet container, not to Undo. Intent item 2 asks for an inline Undo 'reachable by keyboard'. The same applies to the !wasLatest note in the older-links list (line ~375). Fix: key both RevokedNote renders by undoable.invite.id so each new revoke remounts the note and focuses Undo. This came in with the original commit 7dee0e9 and was left in place by the round-2 fix.
  • ℹ️ apps/web/src/features/invites/invite-sheet.tsx:244 - Only the most recent revoke can be undone. undoable holds a single invite, so a second revoke within 8 s replaces the first. Its inline Undo, and the toast the sheet would raise on close, are both gone. Sequence: revoke the latest link A, then within 8 s revoke an older link B. Only B can come back; A stays revoked with no way to restore it (the old code raised one toast per revoke, each with its own Undo). Keeping a list of undoable invites would add state beyond the intent's single inline row, so this is a product call: is losing Undo on the earlier link acceptable?

🔧 Fix applied.
✅ Re-checked - no issues remain.

⏭️ **Test** - skipped

Step was skipped.

✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

musa-kal and others added 9 commits November 14, 2026 19:45
When the periodic check found the session gone, auth-js had already
dropped the stored session inside getUser, so endEndedSession saw nothing
to sign out and never left the note. confirmSession now leaves it as soon
as the check says the session is missing (session_not_found,
user_not_found, session_ended), before any sign out, and the sign-in page
listens for a note that lands after it opened.

Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
The sheet makes the page behind it inert, so tapping the toast's Undo only
closed the sheet, and keyboard users could not reach it. The revoked link
now leaves its "Invite revoked" line with an Undo button in its place,
focus on Undo, and the toast only shows once the panel goes away.

Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
Under "You" the split card read "owes" and "gets back", and the other
languages used third person for paid and got too. The viewer's row now has
its own strings in all five languages.

"You blocked Dee and Gus, so you two cannot share an expense" counted
wrong. The note no longer assumes one person, in every language.

Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
After a lost reply the debts refetch and may already count the payment, so
"You owe Ava 20" sat above a held 30, which read like paying too much.
While the form is held it shows the debt it was sent against, the same
snapshot the settled screen uses.

Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
/payments/:id/edit opened for someone the payment page shows no Edit to
(the blocked side of a tab, on a payment the other person recorded) and
only failed on Save. mayEditPayment is now the one rule for the button and
the route, which sends them back to the payment instead.

Co-authored-by: Ferrin <[email protected]>
Co-authored-by: noorelmosrati <[email protected]>
@musa-kal
musa-kal merged commit 796c3a0 into main Nov 16, 2026
7 checks passed
@musa-kal
musa-kal deleted the fix/dogfood-3 branch November 16, 2026 17:50

This branch was successfully deployed

1 active deployment
preview — b764d11e Deployed Nov 16, 2026 by musa-kal via Deploy web to Cloudflare #117
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant